'use strict';

stareal
    .controller("ActivityListController", function ($scope, $stateParams, $api, $sce, base64, $state, $alert,localStorageService,$lazyLoader) {
        $scope.mypage = 3;
        $scope.activenavbar=1;
        // 加载对应演出种类的内容
        var h=$(window).height()-3.9*parseFloat(document.documentElement.style.fontSize)+"px";
        $("#wrapper_container").height(h);
        var refresh=function(){
            if($scope.activenavbar==1){ //热门
                $scope.hotgoods = new $lazyLoader("app/view/activity",{},true);
                $scope.hotgoods.nextPage();
            }else if($scope.activenavbar==2){ //众筹
                $scope.raisegoods = new $lazyLoader("app/activity/list",{},true);
                $scope.raisegoods.nextPage();
            }

        }
        $scope.switchactivebar=function(index){
            $scope.activenavbar=index;
            if(index==1){
                   refresh();
                if(_czc!=undefined&&_czc!=null&&_czc!='') {
                    _czc.push(["_trackEvent", 'h5-活动-热门', '热门', '查看', 'activity']);
                }
            }else if(index==2){
                //埋点
                    refresh();
                if(_czc!=undefined&&_czc!=null&&_czc!='') {
                    _czc.push(["_trackEvent", 'h5-活动-众筹', '众筹', '查看', 'activity']);
                }
            }

        }
        $scope.switchactivebar(1);
        $scope.bartotla=function(total,count){
            if(count==undefined||count==null||count==''){
                count=0;
            }
            if(count>=total){
                count=total;
            }
            var bar=parseInt(count/total*100);
            $scope.barstyle = {
                "width":bar+'%' ,
                "background":"#f5003a"
            }
            return $scope.barstyle;
        }
        $scope.bartotlashu=function(total,count){
            if(count==undefined||count==null||count==''){
                count=0;
            }
            if(count>=total){
                count=total;
            }
            $scope.barshu=parseInt(count/total*100)+'%';
            return $scope.barshu;
        }

    });